Skip to content

Method: {...}

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.core.model;
28:
29: import javax.annotation.Nonnull;
30: import java.time.ZonedDateTime;
31: import java.util.List;
32: import java.util.Optional;
33: import it.tidalwave.util.Key;
34: import it.tidalwave.role.SimpleComposite;
35: import lombok.AccessLevel;
36: import lombok.AllArgsConstructor;
37: import lombok.Getter;
38: import lombok.RequiredArgsConstructor;
39: import lombok.ToString;
40: import lombok.With;
41:
42: /***********************************************************************************************************************
43: *
44: * A piece of content to be used by something.
45: *
46: * @author Fabrizio Giudici
47: *
48: **********************************************************************************************************************/
49: public interface Content extends Resource, SimpleComposite<Content>
50: {
51: @SuppressWarnings("squid:S1700")
52: public static final Class<Content> _Content_ = Content.class;
53:
54: /** The title of this {@code Content}. */
55: public static final Key<String> P_TITLE = Key.of("title", String.class);
56:
57: /** The unique id of this {@code Content}. */
58: public static final Key<String> P_ID = Key.of("id", String.class);
59:
60: /** The full text contained in this {@code Content}. */
61: public static final Key<String> P_FULL_TEXT = Key.of("fullText", String.class);
62:
63: /** A shortened text contained in this {@code Content}. */
64: public static final Key<String> P_LEADIN_TEXT = Key.of("leadinText", String.class);
65:
66: /** A description this {@code Content}. */
67: public static final Key<String> P_DESCRIPTION = Key.of("description", String.class);
68:
69: /** A contained that works as a template for something. */
70: public static final Key<String> P_TEMPLATE = Key.of("template", String.class);
71:
72: /** The creation date of this {@code Content}. */
73: public static final Key<ZonedDateTime> P_CREATION_DATE = Key.of("creationDateTime", ZonedDateTime.class);
74:
75: /** The latest modification date of this {@code Content}. */
76: public static final Key<ZonedDateTime> P_LATEST_MODIFICATION_DATE = Key.of("latestModificationDateTime", ZonedDateTime.class);
77:
78: /** The publishing date of this {@code Content}. */
79: public static final Key<ZonedDateTime> P_PUBLISHING_DATE = Key.of("publishingDateTime", ZonedDateTime.class);
80:
81: /** A collection of tags associated with this {@code Content}. */
82: public static final Key<List<String>> P_TAGS = new Key<>("tags") {};
83:
84: /*******************************************************************************************************************
85: *
86: * A builder of a {@link Content}.
87: *
88: ******************************************************************************************************************/
89: @AllArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor
90: @Getter @ToString(exclude = "callBack")
91: public final class Builder
92: {
93: // Workaround for a Lombok limitation with Wither and subclasses
94: @FunctionalInterface
95: public static interface CallBack
96: {
97: @Nonnull
98: public Content build (@Nonnull Builder builder);
99: }
100:
101: @Nonnull
102: private final ModelFactory modelFactory;
103:
104: @Nonnull
105: private final CallBack callBack;
106:
107: @With
108: private ResourceFile folder;
109:
110: @Nonnull
111: public Content build()
112: {
113: return callBack.build(this);
114: }
115: }
116:
117: /*******************************************************************************************************************
118: *
119: * Returns the exposed URI mapped to this resource.
120: *
121: * @return the exposed URI
122: *
123: ******************************************************************************************************************/
124: @Nonnull
125: public Optional<ResourcePath> getExposedUri();
126: }